        # Minimal OS entry point
        # QEMU loads kernel at 0x80000000 and jumps here
        # This is a simplified version of xv6's entry.S

.section .text
.global _entry
_entry:
        # Set up stack pointer
        # Use a simple stack at the end of our memory space
        la sp, stack_top
        
        # Clear BSS section (if any)
        la t0, bss_start
        la t1, bss_end
clear_bss:
        beq t0, t1, bss_cleared
        sw zero, 0(t0)
        addi t0, t0, 4
        j clear_bss
bss_cleared:
        
        # Jump to C main function
        call main
        
        # If main returns, enter infinite loop
spin:
        j spin
